﻿using System;
using System.IO;
using System.Threading;
using RestSharp;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hzTrafiic_win
{
    class Program
    {
        static void Main(string[] args)
        {
            var client =
  new RestClient(
    "http://111.0.114.26:8160/arcgis/rest/services/BG/jiaotong1/MapServer/7/query?where=ID>0&outFields=*&f=pjson");
            client.Timeout = -1;
            var request = new RestRequest(Method.GET);
            IRestResponse response = client.Execute(request);
            string dir = Path.GetFullPath("../../download/");
            string fileName = dir + DateTime.Now.Year + '_' + DateTime.Now.Month + '_' + DateTime.Now.Day + '_' +
                              DateTime.Now.Hour + '_' + DateTime.Now.Minute + '_' + DateTime.Now.Ticks + ".json";
            FileStream fs1 = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
            fs1.Close();
            fs1.Dispose();
            File.WriteAllText(fileName, response.Content);

            Console.WriteLine("suc");
            Thread.Sleep(1000 * 60);
        }
    }
}
